package com.sumc.springcloud.feign.config;

import com.sumc.springcloud.feign.service.FeignService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @describe：需要实现fallback工厂来获取它的异常信息
 * @author: Smc
 * @version:v1.0 2020/3/23 12:07   Try to write good code
 */
@Component
public class MyFallbackFactory implements FallbackFactory<FeignService> {
    @Override
    public FeignService create(Throwable throwable) {
        return new FeignService() {
            @Override
            public String sayHello() {
                return throwable.getMessage();
            }
        };
    }
}
